import request from '@/utils/request'
// 出库单管理列表 -----------------------------------------------------------
export function deliveryList(listQuery) {
  return request({
    url: '/wms/delivery/list',
    method: 'get',
    params: listQuery
  })
}
// 取消订单 -----------------------------------------------------------
export function deliveryCancelList(listQuery) {
  return request({
    url: '/wms/delivery/cancelList',
    method: 'get',
    params: listQuery
  })
}
// 取消订单处理 -----------------------------------------------------------
export function deliveryCancelHandler() {
  return request({
    url: '/wms/delivery/cancelHandler',
    method: 'get'
  })
}
// 提交
export function deliveryCheckSubmit(data) {
  return request({
    url: '/wms/delivery/submit',
    method: 'post',
    data
  })
}
// 新增订单 -  承运商
export function carrierList(shipmentCode) {
  return request({
    url: `/wms/Carrier/list?shipmentCode=${shipmentCode}&status=1&pageNum=1&pageSize=100`,
    method: 'post'
  })
}
// 退货提交
export function refundSubmit(data) {
  return request({
    url: '/wms/delivery/refundSubmit',
    method: 'post',
    data
  })
}
// 退货保存
export function refundLocalSave(data) {
  return request({
    url: '/wms/delivery/refundLocalSave',
    method: 'post',
    data
  })
}
// 详情
export function refundDetail(code) {
  return request({
    url: `/wms/delivery/refundDetail/${code}`,
    method: 'get'
  })
}

// 获取 可退货明细 列表
export function getRefundOutItems(code) {
  return request({
    url: '/wms/receive/findReceiveRefundOutItems',
    method: 'get',
    params: { receiveCode: code }
  })
}

// 获取来源单号
export function getSources(params) {
  return request({
    url: `/wms/receive/findReceiveCanRefundList`,
    method: 'get',
    params
  })
}

// 保存
export function deliverySaveSubmit(data) {
  return request({
    url: '/wms/delivery/save',
    method: 'post',
    data
  })
}
// 详情
export function deliveryDetail(code) {
  return request({
    url: `/wms/delivery/detail/${code}`,
    method: 'get'
  })
}
// 作废
export function deliveryBlank(code) {
  return request({
    url: `/wms/delivery/blank/${code}`,
    method: 'get'
  })
}
// 库存分配
export function distribution(code) {
  return request({
    url: `/wms/delivery/distribution/list/${code}`,
    method: 'get'
  })
}
// 库存分配提交
export function deliveryConfirm(code) {
  return request({
    url: `/wms/delivery/confirm/${code}`,
    method: 'get'
  })
}
// 分配完成
export function allocationCompleted(code) {
  return request({
    url: `/wms/delivery/confirm/${code}`,
    method: 'get'
  })
}
// 发货单 部分确认
export function partConfirm(data) {
  return request({
    url: `/wms/delivery/partConfirm`,
    method: 'post',
    data
  })
}
// 自动分配
export function deliveryAutoDistribute(code) {
  return request({
    url: `/wms/delivery/autoDistribute/${code}`,
    method: 'get'
  })
}

// 库存分配详情
export function queryInventory(code) {
  return request({
    url: `/wms/deliveryItem/queryInventory/${code}`,
    method: 'get'
  })
}
// 库存分配详情提交
export function deliveryDistributionCheckSubmit(data) {
  return request({
    url: '/wms/deliveryDistribution/save',
    method: 'post',
    data
  })
}

// 取消分配
export function deliveryCancel(data) {
  return request({
    url: `/wms/delivery/cancel`,
    method: 'post',
    data
  })
}

// 拣货单管理列表 -----------------------------------------------------------
export function pickingList(listQuery) {
  return request({
    url: '/wms/picking',
    method: 'get',
    params: listQuery
  })
}
// 详情
export function pickingDetail(code) {
  return request({
    url: `/wms/picking/${code}`,
    method: 'get'
  })
}
// 波次拣货确认 - 商品详情列表
export function queryPickingRigisters(code) {
  return request({
    url: `/wms/pickingRegister/queryPickingRigisters?wavePickingCode=${code}`,
    method: 'get'
  })
}
// 波次拣货确认 - 商品详情列表 - 确认
export function batchCheck(data) {
  return request({
    url: `/wms/picking/batchCheck`,
    method: 'put',
    data
  })
}
// 波次出库单复核 - 商品详情列表 - 确认
export function outboundBatchCheck(data) {
  return request({
    url: `/wms/outbound/batchRecheck`,
    method: 'put',
    data
  })
}

// 波次拣货确认/复核 - 商品详情 - 缺货列表
export function queryListByInventoryCode(type, parms) {
  return request({
    url: `/wms/${type}/queryListByInventoryCode?${parms}`,
    method: 'get'
  })
}
// 波次拣货确认 - 商品详情 - 缺货列表 - 保存
export function stockOut(data) {
  return request({
    url: `/wms/deliveryDistribution/stockOut`,
    method: 'put',
    data
  })
}
// 波次出库单复核 - 商品详情 - 缺货列表 - 保存
export function recheckStockOut(data) {
  return request({
    url: `/wms/deliveryDistribution/recheckStockOut`,
    method: 'put',
    data
  })
}
// 波次拣货确认 - 订单详情列表
export function queryDeliverylistByWave(parms) {
  return request({
    url: `/wms/delivery/queryDeliverylistByWave?${parms}`,
    method: 'get'
  })
}
// 波次拣货确认 - 订单详情列表 - 解除
export function releaseRelationWithPickingItem(data) {
  return request({
    url: `/wms/delivery/releaseRelationWithPickingItem`,
    method: 'put',
    data
  })
}
// 打印
export function pickingPrint(code) {
  return request({
    url: `/wms/picking/print/${code}`,
    method: 'get'
  })
}
// 打印拣货单（带序号）
export function printSeq(code) {
  return request({
    url: `/wms/picking/printWithOrderNum/${code}`,
    method: 'get'
  })
}
// 批量手动生成拣货单 /wms/delivery/batchGeneratePicking
export function batchGeneratePicking(data) {
  return request({
    url: `/wms/delivery/batchGeneratePicking?codes=${data}`,
    method: 'post'
  })
}
// 提交
export function pickingCheck(data) {
  return request({
    url: '/wms/picking/check',
    method: 'put',
    data
  })
}

// 出库单管理列表 -----------------------------------------------------------
export function outboundList(listQuery) {
  return request({
    url: '/wms/outbound',
    method: 'get',
    params: listQuery
  })
}

// 详情
export function outboundDetail(code) {
  return request({
    url: `/wms/outbound/${code}`,
    method: 'get'
  })
}

//  出库复核
export function outboundReCheck(data) {
  return request({
    url: `/wms/outbound/recheck`,
    method: 'put',
    data
  })
}

//  出库确认
export function outboundCheck(code) {
  return request({
    url: `/wms/outbound/check/${code}`,
    method: 'put'
  })
}

// 出库管理 -> 订单处理  查询
export function getEnumList(code) {
  return request({
    url: `/wms/enumInfo/getEnumList/`,
    method: 'get',
    params: code
  })
}
// 订单处理 -> 数据来源
export function waveList(data) {
  return request({
    url: '/wms/delivery/queryWaveList',
    method: 'post',
    data
  })
}
// 订单处理 -> 数据来源 - 废弃
export function waveListOld(code) {
  return request({
    url: `/wms/delivery/waveList`,
    method: 'get',
    params: code
  })
}
// 订单处理，获取面单
export function batchGetWaybillCode(data) {
  return request({
    url: `/wms/delivery/batchGetWaybillCode`,
    method: 'post',
    data
  })
}
//  商品查询
export function waveQueryGoods(listQuery) {
  return request({
    url: `/wms/delivery/waveQueryGoods`,
    method: 'get',
    params: listQuery
  })
}
// / 订单管理 - 爆品商品查询
export function waveQueryHotGoods(listQuery) {
  return request({
    url: `/wms/delivery/waveQueryHotGoods`,
    method: 'get',
    params: listQuery
  })
}
// 出库管理 -> 生成波次
export function saveWave(params) {
  const url = params.maxOrderQuantity ? `/wms/delivery/genWave?maxOrderQuantity=${params.maxOrderQuantity}&isReview=${params.isReview}` : `/wms/delivery/genWave?isReview=${params.isReview}`
  return request({
    url,
    method: 'post',
    data: params.codes
  })
}
//  生成波次提示信息
export function waveTips(params) {
const url = params.maxOrderQuantity ? `/wms/delivery/waveTips?maxOrderQuantity=${params.maxOrderQuantity}` : `/wms/delivery/waveTips`
  return request({
    url,
    method: 'post',
    data: params.codes
  })
}
// 出库管理 -> 列表 -> 详情
export function shipmentDetail(code) {
  return request({
    url: `/wms/delivery/detail/${code}`,
    method: 'get'
  })
}

// 出库管理 -> 发货单管理 -> 打印面单
export function printExpress(data) {
  return request({
    url: `/wms/delivery/printExpress`,
    method: 'post',
    data
  })
}
// 出库管理 -> 发货单管理 -> 更新面单信息
export function batchUpdateWaybill(data) {
  return request({
    url: `/wms/delivery/batchUpdateWaybill`,
    method: 'post',
    data
  })
}
// 出库管理 -> 出库管理 -> 打印面单
export function printExpressOutbound(data) {
  return request({
    url: `/wms/outbound/printExpress?outboundCodes=${data}`,
    method: 'post'
  })
}
// 出库管理 -> 发货单管理 -> 列表 获取面单
export function getWaybillCode(code) {
  return request({
    url: `/wms/delivery/getWaybillCode?code=${code}`,
    method: 'get'
  })
}

// 获取标准面单模板、获取自定义面单模板
export function getPrintTemplate(parms) {
  return request({
    url: `wms/cloudprintStandardTemplates/listTemplates?code=${parms.code}&type=${parms.type}`,
    method: 'get'
  })
}
// 打印总拣单
export function printGeneralPickOrders(data) {
  return request({
    url: `/wms/picking/printGeneralPickOrders`,
    method: 'post',
    data
  })
}
// 记录打印总拣单次数
export function batchGeneralPickCount(data) {
  return request({
    url: '/wms/picking/batchGeneralPickCount',
    method: 'post',
    data
  })
}
// 更新同一个波次下的拣货单面单打印次数及订单打印次数
export function updatePrintCount(code) {
  return request({
    url: `/wms/picking/updatePrintCount?wavePickingCode=${code}`,
    method: 'post'
  })
}
// 面单打印次数
export function printCount(deliveryCode) {
  return request({
    url: `/wms/delivery/updatePrintCount/${deliveryCode}`,
    method: 'post'
  })
}
// 面单打印次数2，根据订单号累计
export function batchUpdatePrintCount(data) {
  return request({
    url: '/wms/delivery/batchUpdatePrintCount',
    method: 'post',
    data
  })
}
// 打印运单2
export function printPickOrder(pickingCode) {
  return request({
    url: `/wms/picking/printExpress/${pickingCode}`,
    method: 'post'
  })
}
// 入驻商 下拉查询
export function shipments() {
  return request({
    url: `/wms/warehouseShipment/business/shipments`,
    method: 'get'
  })
}
// 承运商 下拉查询
export function carrierDropdown() {
  return request({
    url: `/wms/Carrier/dropdown`,
    method: 'get'
  })
}
// 异常订单 列表
export function abnormalList(listQuery) {
  return request({
    url: '/wms/delivery/abnormalList',
    method: 'get',
    params: listQuery
  })
}
// 异常订单 更新状态
export function updateStatus(data) {
  return request({
    url: '/wms/delivery/updateDeliveryStatus',
    method: 'get',
    data
  })
}
// 取消波次 /delivery/cancelWaveTipsPrompt
export function cancelWaveTipsPrompt(wavePickingCode) {
  return request({
    url: `/wms/delivery/cancelWaveTipsPrompt?wavePickingCode=${wavePickingCode}`,
    method: 'get'
  })
}
// 取消波次 /delivery/cancelWaveTips
export function cancelWaveTips(wavePickingCode) {
  return request({
    url: `/wms/delivery/cancelWaveTips?wavePickingCode=${wavePickingCode}`,
    method: 'get'
  })
}
// 更改承运商
export function changeCarrier(data) {
  return request({
    url: '/wms/delivery/changeCarrier',
    method: 'post',
    data
  })
}
// 获取地区信息
export function queryProvinceCitys() {
  return request({
    url: '/arpa-basic-api/areaProvince/queryProvinceCitys',
    method: 'get'
  })
}
// 通过波次号获取打印信息
export function getInfoByWavePickingCode(wavePickingCode) {
  return request({
    url: `/wms/picking/wavePrintWaybill/${wavePickingCode}`,
    method: 'post'
  })
}
// 批量出库
export function batchOutboundConfirm(data) {
  return request({
    url: `/wms/outbound/batchOutboundConfirm`,
    method: 'put',
    data
  })
}
// 批量复核出库
export function batchReviewOutbound(data) {
  return request({
    url: `/wms/outbound/batchRecheckOutboundConfirm`,
    method: 'put',
    data
  })
}
// 批量更新拣货单（序号）打印次数增加
export function batchPickSortCount(data) {
  return request({
    url: `/wms/picking/batchPickSortCount`,
    method: 'post',
    data
  })
}
// 判断货主是否需要复核
export function judgeRecheck(data) {
  return request({
    url: '/arpa-basic-api/shipment/judgeRecheck',
    method: 'post',
    data
  })
}
